class_name PlayerRollState
extends GameplayState

@onready var player: Player = $"../../../"


func _on_enter() -> void:
	player.play_animation("roll")

	player.add_tag(GameplayTagLibrary.State_Ground_Crouch)
	player.add_tag(GameplayTagLibrary.State_Ground_Move_Roll)

	player.state_checker.change_to_crouch_collision()


func _on_update(delta: float) -> void:
	player.velocity.x = player.face_direction * player.get_attribute("roll_speed").current_value * delta

	if not player.animator.is_playing():
		change_state("GhostState", func(): pass)
		return


func _on_exit() -> void:
	player.remove_tag(GameplayTagLibrary.State_Ground_Crouch)
	player.remove_tag(GameplayTagLibrary.State_Ground_Move_Roll)

	player.state_checker.change_to_stand_collision()
